﻿using System;
using System.Collections.Generic;
using System.Linq;
using DataAccess;

namespace BussinesLogic
{
    public class Portada : BaseObject
    {
        #region Propiedades Publicas
        public int id { get; set; }
        public string NoExpediente { get; set; }
        public int NumFolios { get; set; }
        public string Asunto { get; set; }
        public string UnidadRemitente { get; set; }
        public string FuncionarioRemitente { get; set; }
        public string CodPortada { get; set; }
        public DateTime Fecha { get; set; }
        public string CodDocumento { get; set; }
        #endregion


        public Portada()
        {
            Fecha = DateTime.Now;

        }

        public static Portada getPortadabyExpediente(string noExpediente)
        {
            DataAccess.Factory.PortadaFactoryDao tmpFac = new DataAccess.Factory.PortadaFactoryDao();

            return tmpFac.getPortadabyExpediente(noExpediente);
        }

        public static Portada getPortadabyDocumento(string CodDocumento)
        {
            DataAccess.Factory.PortadaFactoryDao tmpFac = new DataAccess.Factory.PortadaFactoryDao();

            return tmpFac.getPortadabyDocumento(CodDocumento);
        }

        public static Portada getPortadabyId(int id)
        {
            DataAccess.Factory.PortadaFactoryDao tmpFac = new DataAccess.Factory.PortadaFactoryDao();

            return tmpFac.getPortadabyId(id);
        }

        public int Create()
        {
            try
            {
                DataAccess.Factory.PortadaFactoryDao tmpFac = new DataAccess.Factory.PortadaFactoryDao();
                this.id = tmpFac.createPortada(this.xmlObjectDescription());
            }
            catch (Exception ex)
            {
                return -1;
            }
            return 0;
        }
        public int Update()
        {
            try
            {
                DataAccess.Factory.PortadaFactoryDao tmpFac = new DataAccess.Factory.PortadaFactoryDao();
                this.id = tmpFac.updatePortada(this.xmlObjectDescription());
            }
            catch (Exception ex)
            {
                return -1;
            }
            return 0;
        }

        public string toXML()
        {
            return this.xmlObjectDescription();
        }
        
    }
}
